<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>规格概述</title>
</head>
<body>
    <h1>规格概述</h1>
    <h2>ECMAScript规格的阅读方法</h2>

    <script>
        // 规格文件的基本格式
        /*
        4.3.4 Abstract Operations 抽象操作
        4.3.4.1 Get (O, P) 获取操作
        The abstract operation Get is used to retrieve the value of a specific property of an object.
        */

        // 示例：Object.prototype.toString的规格
        const obj = {};
        console.log(Object.prototype.toString.call(obj)); // "[object Object]"
        console.log(Object.prototype.toString.call([])); // "[object Array]"
        console.log(Object.prototype.toString.call(null)); // "[object Null]"

        // 示例：数组空位的处理
        const arr1 = [, , ,];
        console.log(arr1.length); // 3
        console.log(0 in arr1); // false

        const arr2 = new Array(3);
        console.log(arr2.length); // 3
        console.log(0 in arr2); // false

        // 示例：相等运算符的规格
        console.log(null == undefined); // true
        console.log(null === undefined); // false

        // 示例：数组的map方法
        const arr = [1, 2, 3];
        const result = arr.map(x => x * 2);
        console.log(result); // [2, 4, 6]

        // 空位的处理
        const arr3 = [1, , 3];
        const result2 = arr3.map(x => x * 2);
        console.log(result2); // [2, undefined, 6]
    </script>
</body>
</html> 